//
//  OrderConditionReusableView.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/6.
//

import UIKit

class OrderConditionReusableView: UICollectionReusableView {

    var groupTitle:String = ""
    var titleLab:UILabel!
    var groupTitleLab:UILabel!
    var Myframe:CGRect!

    override init(frame: CGRect) {
        super.init(frame: frame)
        Myframe = frame
        groupTitleLab = UILabel.init()
        groupTitleLab.backgroundColor = UIColor.white
        groupTitleLab.font = UIFont.boldSystemFont(ofSize: 14)
        groupTitleLab.textAlignment = .center
        self.addSubview(groupTitleLab)
        titleLab = UILabel.init()
        titleLab.textColor = UIColor.init(hexString: "#F48080")
        titleLab.font = UIFont.systemFont(ofSize: 10)
        titleLab.layer.cornerRadius = 7.5
        titleLab.layer.masksToBounds = true
        titleLab.layer.borderColor = UIColor.init(hexString: "#F48080").cgColor
        titleLab.layer.borderWidth = 0.5
        titleLab.textAlignment = .center
        titleLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_required)
        self.addSubview(titleLab)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setGroupTitle(groupTitle:String) {
        self.groupTitle = groupTitle
        
        let strWidth = groupTitle.getWidth(UIFont.systemFont(ofSize: 14))
        groupTitleLab.frame = CGRect.init(x: 15, y: 0, width: strWidth + 10, height: Myframe.size.height)
        groupTitleLab.text = groupTitle
        
        let twoWidth = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_required).getWidth(UIFont.systemFont(ofSize: 10))
        titleLab.frame = CGRect.init(x: 15, y: 0, width: twoWidth + 10, height: 15)
        titleLab.center.y = groupTitleLab.center.y
    }
}
